﻿using System.Collections.Generic;

namespace DataAccess
{
    public class PropertyMap
    {
        private IDictionary<string, int> _map = new Dictionary<string, int>();

        private HashSet<string> _ignored = new HashSet<string>();

        #region Methods

        internal int GetIndex(string name)
        {
            if (!_map.ContainsKey(name))
            {
                return -1;
            }

            return _map[name];
        }

        internal bool IsIgnored(string propertyName)
        {
            return _ignored.Contains(propertyName);
        }

        #endregion

        #region Fluent methods

        public static PropertyMap Map()
        {
            return new PropertyMap();
        }

        public PropertyMap Property(string name, int index)
        {
            _map.Add(name, index);

            return this;
        }

        public PropertyMap Ignore(string name)
        {
            _ignored.Add(name);

            return this;
        }
        
        #endregion
    }
}
